<%@ page language="java" import="java.util.*,cat.commons.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML">
<html>
  <head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/maintable.css" ></link>
	<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.8.0.js"></script> 
	<script type="text/javascript">
		$(function(){	
			$("table tr").mouseover(function(){
				$(this).css("background","#D3EAEF");
				$(this).siblings().css("background","white");
			});
		});
	</script>

	<script>
		function subForm(pageIndex)
		{
		    //pageIndex 不传入,表示,是点击"转到"按钮的时候触发的
		    if(pageIndex){
		    	window.location.href="${pageContext.request.contextPath}/PermServlet.do?flag=listadmin&pageIndex="+pageIndex;
		    }
		    else{
		        window.location.href="${pageContext.request.contextPath}/PermServlet.do?flag=listadmin&pageIndex="+document.getElementById("pageIndex").value;
		    }	
		}
		
	</script>
  </head> 
  <body>
		 <div class ="div_title">
				<div class="div_titlename"> <img src="images/san_jiao.gif" ><span>管理员基本信息列表</span></div>
		 </div>

		 <table class="main_table" >
		       <tr>
		 			<th>账号</th><th>状态</th><th>用户角色</th><th>最后更新日期</th><th>操作</th>
		 		</tr>
		 		<c:forEach var="admin" items="${adminList}">
		 		<tr>
		 				<td>${admin.adminName }</td>	
		 				<td>
			 				<c:choose>
			 					<c:when test="${admin.state==2}">已锁定</c:when>
			 					<c:when test="${admin.state==1}"></c:when>	
			 				</c:choose>
		 				</td>	
		 				<td>${admin.roleName }</td>	
		 				<td><fmt:formatDate value="${admin.editDate}"   pattern="yyyy-MM-dd - hh:mm" /></td>	
		 				<td>	
		 					<c:if test="${admin.state=='1' }">
		 						 <a href="${pageContext.request.contextPath }/perm/adminrole_edit.jsp?adminId=${admin.id}">角色分配</a> 
		 					</c:if>
		 				</td>
		 		</tr>
		   		 </c:forEach>
		 </table>
				
		<div class="div_page" >
			  <div class="div_page_left">    共有 <label>${pageInfo.rowCount }</label> 条记录，当前第 <label>${pageInfo.pageIndex }</label> 页，共 <label>${pageInfo.pageCount }</label> 页	</div>
			  <div class="div_page_right" > 	 
			  	<c:choose>
			  		<c:when test="${pageInfo.hasPre }" >
		  			    <button onclick="subForm(1)" >首页</button>
		  	 			<button onclick="subForm(${pageInfo.pageIndex-1})">上一页</button>	
			  		</c:when>
			  		
			  		<c:otherwise>
			  			 首页
		  	 			 上一页
			  		</c:otherwise>	
			  	</c:choose>
			  	
			 	<c:choose>
			  		<c:when test="${pageInfo.hasNext}" >
		  			    <button onclick="subForm(${pageInfo.pageIndex+1})">下一页</button>
		  	 			<button onclick="subForm(${pageInfo.pageCount})">尾页</button>	
			  		</c:when>
			  		
			  		<c:otherwise>
			  			下一页 
		  	 		         尾页
			  		</c:otherwise>	
			  	</c:choose>
	
			  	 <button onclick="subForm()">转到</button>
			  	 <input type="text" name="pageIndex" id="pageIndex" value="${pageInfo.pageIndex }" /> 页
			   </div>	
		</div>	
  </body>
</html>
